home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / rayshade / graphtal.lzh / Graphtal.Amiga / Value.h < prev    next >
C/C++ Source or Header  |  1992-11-20  |  2KB  |  84 lines

  1. /*
  2.  * Value.h - definition for value class, which stores real and string 
  3.  *           values.
  4.  *
  5.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  6.  *                     University of Berne, Switzerland
  7.  * Portions Copyright (C) 1990, Jonathan P. Leech
  8.  * All rights reserved.
  9.  *
  10.  * This software may be freely copied, modified, and redistributed
  11.  * provided that this copyright notice is preserved on all copies.
  12.  *
  13.  * You may not distribute this software, in whole or in part, as part of
  14.  * any commercial product without the express consent of the authors.
  15.  *
  16.  * There is no warranty or other guarantee of fitness of this software
  17.  * for any purpose.  It is provided solely "as is".
  18.  *
  19.  */
  20.  
  21. #ifndef Value_H
  22. # define Value_H
  23.  
  24. #include <iostream.h>
  25. #include "rcString.h"
  26. #include "mathutilities.h"
  27.  
  28. //___________________________________________________________ Value
  29.  
  30. enum ValueType { REAL, STRING };
  31. enum ArgumentType { RR, RS, SR, SS, UNKNOWN };
  32.  
  33. class Value 
  34. {
  35. public:
  36.   Value();
  37.   Value(real);
  38.   Value(const char*);
  39.   Value(const rcString&);
  40.   Value(const Value&);
  41.  
  42.   ~Value();
  43.  
  44.   const Value& operator=(const Value&);
  45.  
  46.   operator real() const;
  47.   operator rcString() const;
  48.  
  49.   int toReal(real&) const;
  50.   rcString toString() const;
  51.  
  52.   Value operator-();
  53.   Value operator+(const Value&);
  54.   Value operator-(const Value&);
  55.   Value operator*(const Value&);
  56.   Value operator/(const Value&);
  57.   Value operator%(const Value&);
  58.   
  59.   Value operator!();
  60.   Value operator&&(const Value&);
  61.   Value operator||(const Value&);
  62.   Value operator==(const Value&);
  63.   Value operator!=(const Value&);
  64.   Value operator< (const Value&);
  65.   Value operator<=(const Value&);
  66.   Value operator> (const Value&);
  67.   Value operator>=(const Value&);
  68.  
  69.   friend ostream& operator<< (ostream&, const Value&);
  70.  
  71. private:
  72.   ValueType type;
  73.   union {
  74.     real realVal;
  75.     rcString* stringVal;
  76.   }; 
  77.   
  78.   ArgumentType binary_type(const Value&);
  79. };
  80.  
  81. typedef Value* ValuePtr;
  82.  
  83. #endif // Value_H 
  84.